package com.example.x.dnuifood_929dx.controller;

import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.Toast;

import com.example.x.dnuifood_929dx.R;
/**
 * Created by X on 2018/10/18.
 */

public abstract  class BaseActivity extends AppCompatActivity {
    protected  int layout_file=R.layout.activity_main;
    abstract void initViews();//控件初始化
    abstract void initEvents();//事件初始化
    abstract void initData();//数据初始化

    void setLayout(int layout_file){
        setContentView(layout_file);

    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setLayout(layout_file);
        initViews();
        initEvents();
        initData();

    }
    public String getUser_id(){
        SharedPreferences sp;
        sp=getSharedPreferences("userInfo", Context.MODE_PRIVATE);
        return sp.getString("user_id","");
    }
    public String getUser_password(){
        SharedPreferences sp;
        sp=getSharedPreferences("userInfo",Context.MODE_PRIVATE);
        return  sp.getString("userpass","");
    }
    public SharedPreferences getSPFile(){
        SharedPreferences sp;
        sp=getSharedPreferences("photo",Context.MODE_PRIVATE);
        return sp;
    }
    public String getMobilenum(){
        SharedPreferences sp;
        sp=getSharedPreferences("userInfo",Context.MODE_PRIVATE);
        return  sp.getString("telephone","");
    }
    public String getAddress(){
        SharedPreferences sp;
        sp=getSharedPreferences("userInfo",Context.MODE_PRIVATE);
        return  sp.getString("address","");
    }
    public void showToast(String content){
        Toast.makeText(this,content,Toast.LENGTH_LONG).show();
    }
}
